package com.lyz.dataStructure.algorithm.SAN3602020;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/8/31 17:51
 *@Description:
 **/
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static Set<Integer> set = new HashSet<>();
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int N = in.nextInt(), M = in.nextInt();
        int[] dp = new int[M];
        for (int i = 0; i < M; i++) {
            dp[i] = in.nextInt();
        }

        for (int i = 0; i < N; i++) {
            dfs(dp, 0, i, N, i);
        }
        System.out.println(set.size());
    }

    private static void dfs(int[] d, int idx, int pos, int n, int fa) {
        if (idx >= d.length && pos >= 0 && pos < n) {
            set.add(pos);
            return;
        }
        if (d[idx] <= pos) {
            dfs(d, idx + 1, pos - d[idx], n, fa);
        }

        if (d[idx] <= n - pos - 1) {
            dfs(d, idx + 1, pos + d[idx], n, fa);
        }
    }
}

